<template>
    <el-menu class="el-menu-demo" mode="horizontal" router="true" :default-active="activeIndex">
        <el-menu-item index="/login" @click="changeName">
            <el-icon>
                <UserFilled/>
            </el-icon>
            <div>{{ school_id }}</div>
        </el-menu-item>
        <el-menu-item v-if="identity==='student'" index="/getCrouse">获取课表</el-menu-item>
        <el-menu-item v-if="identity==='student'" index="/getPlan">课程助手</el-menu-item>
        <el-menu-item v-if="identity==='admin'" index="/adminhome">课程审核</el-menu-item>
        <el-menu-item index="" @click="toggleDark()">
            <button class="border-none w-full bg-transparent cursor-pointer">
                <i inline-flex i="dark:ep-moon ep-sunny"/>
            </button>
            <div>*</div>
        </el-menu-item>
    </el-menu>
</template>

<script lang="ts" setup>
import {toggleDark} from '~/composables';
import {ref, watch} from 'vue'

import {ElMessage, ElMessageBox} from 'element-plus'


const activeIndex = ref('/getCrouse')


let school_id = ref(localStorage.getItem('school_id') || 'iSZTU');

let identity = ref(localStorage.getItem('identity') || '');

// 监听本地存储中的name
watch(() => localStorage.getItem('school_id'), (newID: any) => {
    school_id = newID
    console.log(newID)
});

function changeName() {
    school_id.value = 'iSZTU'
    identity.value = ''
}




</script>
